<html>
<head><meta charset="utf-8"><title>Determining rmeta hash · t-cargo · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/index.html">t-cargo</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Determining.20rmeta.20hash.html">Determining rmeta hash</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="232316695"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Determining%20rmeta%20hash/near/232316695" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Will Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Determining.20rmeta.20hash.html#232316695">(Mar 29 2021 at 18:48)</a>:</h4>
<p>When cargo generates files like <code>libfoo-bfaf942440547afb.rmeta</code> how is the hash determined? If I read the repository correctly, is it a hex encoding of the sha256 hash of some information about the package's dependencies and/or version?</p>
<p>I ask because I'm trying to use the unit-graph feature to determine the rmeta path for a package's dependency. I was naively grepping for <code>libfoo-*.rmeta</code>but that won't work if the package depends on two different versions of foo.</p>



<a name="232317054"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Determining%20rmeta%20hash/near/232317054" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Determining.20rmeta.20hash.html#232317054">(Mar 29 2021 at 18:51)</a>:</h4>
<blockquote>
<p>When cargo generates files like <code>libfoo-bfaf942440547afb.rmeta</code> how is the hash determined? If I read the repository correctly, is it a hex encoding of the sha256 hash of some information about the package's dependencies and/or version?</p>
</blockquote>
<p>Correct</p>



<a name="232317172"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Determining%20rmeta%20hash/near/232317172" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> bjorn3 <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Determining.20rmeta.20hash.html#232317172">(Mar 29 2021 at 18:52)</a>:</h4>
<p>I have never used the unit graph feature.</p>



<a name="232317877"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Determining%20rmeta%20hash/near/232317877" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Will Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Determining.20rmeta.20hash.html#232317877">(Mar 29 2021 at 18:57)</a>:</h4>
<p>(paging <span class="user-mention" data-user-id="120518">@Eric Huss</span> since you opened the unit-graph tracking issue)</p>
<p>Would anyone be opposed if I added a feature to unit-graph that puts the dep hash into a new <code>units[].dependencies[].dep_hash</code> field?</p>



<a name="232319815"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Determining%20rmeta%20hash/near/232319815" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Determining.20rmeta.20hash.html#232319815">(Mar 29 2021 at 19:11)</a>:</h4>
<p>The unit-graph feature isn't really intended to be used in that way, so I would be a little wary of extending it in that way.</p>
<p>I'm not sure what you are trying to accomplish, but would it be possible using the JSON output (which provides artifact messages) or something like RUSTC_WRAPPER (or RUSTC_WORKSPACE_WRAPPER)?</p>



<a name="232330940"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Determining%20rmeta%20hash/near/232330940" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Will Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Determining.20rmeta.20hash.html#232330940">(Mar 29 2021 at 20:31)</a>:</h4>
<p>I'm trying to make an analysis tool that uses rustc_private. To invoke rustc on an arbitrary Cargo project, I need to know the set of rustc flags needed, eg <code>--extern</code> flags. See my WIP: <a href="https://github.com/willcrichton/generate-rustc-flags/blob/master/src/lib.rs#L84">https://github.com/willcrichton/generate-rustc-flags/blob/master/src/lib.rs#L84</a></p>
<p>An issue with using JSON logs or RUSTC_WRAPPER is that Cargo won't actually try to run rustc unless the corresponding cache is invalidated. I'm not sure how to find that cache or know which file to delete.</p>



<a name="232333185"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Determining%20rmeta%20hash/near/232333185" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Eric Huss <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Determining.20rmeta.20hash.html#232333185">(Mar 29 2021 at 20:47)</a>:</h4>
<p><span class="user-mention" data-user-id="265377">@Will Crichton</span> With <code>RUSTC_WORKSPACE_WRAPPER</code>, cargo uses separate hashing for filenames so they aren't shared with a normal <code>cargo check</code>.  If your wrapper doesn't output any files, then cargo will always re-run the command (since the output is missing).  That's one option to "force" your analysis tool to always run.</p>
<p>This sounds similar to what <code>cargo miri</code> does.  It hijacks rustc (using <code>RUSTC_WRAPPER</code>), and runs a rustc_private executable to analyze the code.</p>



<a name="232334691"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/246057-t-cargo/topic/Determining%20rmeta%20hash/near/232334691" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Will Crichton <a href="https://rust-lang.github.io/zulip_archive/stream/246057-t-cargo/topic/Determining.20rmeta.20hash.html#232334691">(Mar 29 2021 at 20:57)</a>:</h4>
<p>Ah looking at miri is a great point, I will check that out. Thanks for the help!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>